Skip to content

fix(AppAlert): prevent layout shift on initial render for new users#1453

Open
devjhex wants to merge 1 commit intoOpenBeta:developfrom
devjhex:fix/app-alert-layout-shift
Open

fix(AppAlert): prevent layout shift on initial render for new users#1453
devjhex wants to merge 1 commit intoOpenBeta:developfrom
devjhex:fix/app-alert-layout-shift

Conversation

@devjhex
Copy link
Copy Markdown

@devjhex devjhex commented Mar 27, 2026


name: Pull request
about: Create a pull request
title: 'Fix layout shift for main alert component'
labels: 'bug fix'
assignees: ''


What type of PR is this?(check all applicable)

  • refactor
  • feature
  • bug fix
  • documentation
  • optimization
  • other

Description

What this PR achieves

AppAlert was initializing with useState(false) which caused a layout shift for every first-time visitor. Since useEffect runs after the first render, the alert would always pop in after the page painted, pushing content down.

Changing to useState(true) means the alert renders visible from the start — no shift for new users. The only tradeoff is a brief flash for returning users who already dismissed it (cookie exists), but this is barely noticeable especially on fast devices and affects a much smaller group.

Related Issues

Issue #1452

Screenshots, recordings

Illustration

shift-illustration

Notes

  • First-time visitors — the most critical audience — now get a completely clean experience with zero layout shift regardless of their network conditions. The only tradeoff is a brief flash for returning users who already dismissed the alert, which is practically invisible on fast devices and only affects a group that has already seen the site before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant